<template>
    <!-- 修改资料 -->
    <div>
        <el-form label-width="120px" :model="form" label-position="right" ref="formRef" disabled class="borderNone">
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="模块ID" prop="moduleId">
                        <el-input v-model="form.moduleId"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="流程名称" prop="name">
                        <el-input v-model="form.name"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="公司" prop="companyId">
                        <el-input v-model="form.companyName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="工作组" prop="groupId">
                        <el-input v-model="form.groupName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="发起人员范围" prop="rangeShowType">
                        <el-input v-model="form.rangeShowTypeName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="功能模块" prop="metaModuleName">
                        <el-input v-model="form.metaModuleName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>


            <el-form-item v-if="form.rangeShowType == '1'" label="发起部门">
                <el-input v-model="rangeEmployeeName" type="textarea"></el-input>
            </el-form-item>
            <el-form-item v-if="form.rangeShowType == '2'" label="发起人员">
                <el-input v-model="rangeEmployeeName"></el-input>
            </el-form-item>
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="单据URL" prop="reviewPageUrl">
                        <el-input v-model="form.reviewPageUrl"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="管理员" prop="adminId">
                        <el-input v-model="form.adminName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="绑定表名">
                        <el-input v-model="form.bindTableName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="审核处理服务名">
                        <el-input v-model="form.approvalHandlerService"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="上传附件">
                        <el-image v-if="checkType(form) == 'image'" alt="上传图片" :src="form.fileFullPath"
                            @click="openDialog(form.fileFullPath)" style="width: 30%;"></el-image>
                        <video style="width: 30%;" v-else-if="checkType(form) == 'video'" :src="form.fileFullPath"
                            controls></video>
                        <span v-else>{{ form.fileName }}</span>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="备注">
                        <el-input v-model="form.remark" type="textarea"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <sc-title title="表单控件设置"></sc-title>
            <el-scrollbar height="200px">
                <ts-form-table v-model="dataList" :addTemplate="addTemplate" disabled placeholder="暂无数据">
                    <template #tableContent>
                        <el-table-column prop="id" label="id">
                        </el-table-column>
                        <el-table-column prop="name" label="名称">
                        </el-table-column>
                        <el-table-column prop="fieldName" label="表达式">
                        </el-table-column>
                        <el-table-column prop="typeName" label="控件类型">
                        </el-table-column>
                        <el-table-column prop="codeKindName" label="数据源">
                        </el-table-column>
                    </template>
                </ts-form-table>
            </el-scrollbar>

        </el-form>
        <div class="button-position">
            <el-button @click="updateVisible">取 消</el-button>
            <el-button type="primary" @click="add(formRef)">确 定</el-button>
        </div>
        <el-dialog v-model="dialogVisible">
            <img :src="dialogImageUrl" alt="预览" w-full style="width: 100%;" />
        </el-dialog>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { Check, Close } from '@element-plus/icons-vue';
import Api from '@/api/model/workflow.js'
import { convertStr } from '@/utils/arr.js'
import tsFormTable from '@/components/scFormTable/index.vue'
import { checkType } from '@/utils/checkType.js'
const emit = defineEmits(['updatetable'])
// 添加用户数据的对象
const form = ref({});
const dataList = ref([])
const formRef = ref()
const rangeEmployeeName = ref()
const dialogVisible = ref(false)
const dialogImageUrl = ref()
const props = defineProps({
    paramsData: {
        type: Object,
        defalut: {}
    }
})
onMounted(() => {
    getInit()
})
const openDialog = (val) => {
    dialogImageUrl.value = val
    dialogVisible.value = true
}
const getInit = async () => {
    var res = await Api.process.detail.post(props.paramsData);
    if (res.code == 200) {
        form.value = res.data
        dataList.value = res.dataList
        rangeEmployeeName.value = convertStr(res.data.rangeEmployeeList, 'name')
    }
}
const updateVisible = (val) => {
    emit('updatetable')
}



</script>

<style lang="less" scoped>
:deep(.el-select) {
    width: 100%;
}

.borderNone {
    :deep(.el-input__wrapper) {
        box-shadow: 0 0 0 0px var(--el-input-border-color, var(--el-border-color)) inset;
        cursor: default;
        background-color: transparent; //背景颜色透明
        border-bottom: 1px solid #999;
        border-radius: 0;

        .el-input__inner {
            cursor: default !important;
        }
    }

    :deep(.el-textarea__inner) {
        box-shadow: 0 0 0 0px var(--el-input-border-color, var(--el-border-color)) inset;
        cursor: default;
        background-color: transparent; //背景颜色透明
        border-bottom: 1px solid #999;
        border-radius: 0;
    }
}
</style>

